package com.dmz.task.controller;


import com.dmz.task.bean.dto.*;
import com.dmz.task.bean.entity.TDocInfo;
import com.dmz.task.model.ApiResult;
import com.dmz.task.model.PageModel;
import com.dmz.task.service.DocInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * @author lee
 */
@RestController
@RequestMapping("/doc")
public class DocInfoController {

    @Autowired
    private DocInfoService docInfoService;

    /**
     * 分页查询项目
     *
     * @return
     */
    @PostMapping("/query")
    public ApiResult<PageModel<TDocInfo>> query(@RequestBody DocInfoQueryDto dto) {
        return ApiResult.success(docInfoService.query(dto), "查询成功!");
    }

    /**
     * 新增任务
     *
     * @return
     */
    @PostMapping("/add")
    public ApiResult<Boolean> add(@Validated @RequestBody DocInfoAddDto dto) {
        return ApiResult.success(docInfoService.add(dto), "新增成功!");
    }


    /**
     * 修改任务
     *
     * @return
     */
    @PostMapping("/edit")
    public ApiResult<Boolean> edit(@Validated @RequestBody DocInfoEditDto dto) {
        return ApiResult.success(docInfoService.edit(dto), "修改成功!");
    }

    /**
     * 删除任务
     *
     * @return
     */
    @GetMapping("/delete")
    public ApiResult<?> delete(@RequestParam("id") Long id) {
        return ApiResult.success(docInfoService.delete(id), "删除成功!");
    }


}
